package com.ybliang.plat.common.data.vo.resp;

import com.ybliang.plat.serviceapp.common.exception.Error;

public class Resp {
	
	public int code;
	
	/**
	 * 返回信息
	 */
	public String msg;
	
	public Object data;

	private Resp() {}

	private static Resp of(int code, String msg, Object data){
		Resp resp = new Resp();
		resp.code = code;
		resp.msg = msg;
		resp.data = data;
		return resp;
	}
	
	public static Resp success(){
		return Resp.of(0, "ok", null);
	}

	public static Resp success(Object data){
		return Resp.of(0, "ok", data);
	}

	public static Resp fail(int code, String message){
		return Resp.of(code, message, null);
	}

	public static Resp fail(Error error, String msg){
		return Resp.of(error.getCode(), msg, null);
	}
	
	
}
